﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;

namespace Sendz.WebUI.Helpers
{
    public class CookieHelpers
    {
        public bool SetCookie(string name, string value, int expires = 14)
        {
            try 
            {
                HttpContext.Current.Response.SetCookie(new HttpCookie(name, value) { Expires = DateTime.Now.AddDays(expires) });
            }
            catch 
            {
                return false;
            }
            return true;
        }

        public bool RemoveCookie(string name)
        {
            try
            {
                HttpContext.Current.Response.Cookies[name].Expires = DateTime.Now.AddDays(-1);
            }
            catch
            {
                return false;
            }
            return true;
        }
    }
}